home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0696.zip / DWYER.ZIP / MAXOFT.TST / SETMAXT.C < prev   
C/C++ Source or Header  |  1996-01-10  |  2KB  |  70 lines

  1. /* ============ */
  2. /* SetMaxT.c    */
  3. /* ============ */
  4. #include <defcodes.h>
  5. #include <maxtdefs.h>
  6. #include <miscdefs.h>
  7.  
  8. #define    ACT(X)    #X
  9.  
  10. #define    CLAMP(Out, Var, Lo, Hi)    Out = __min(Hi, __max(Lo, Var))
  11.  
  12. #define    NEED_ALL(Label)    "Enter "Label
  13.  
  14. #define    NEED_USER_ENTRY(LABEL, LO, HI) \
  15.     NEED_ALL(LABEL" ["ACT(LO)"-"ACT(HI)"]: ")
  16.  
  17. #define    LEN_LABEL   "Length of Each Sequence"
  18. #define    SQNCE_LABEL "Number of Sequences"
  19.  
  20. #define    REPORT_USER_INT_ENTRY(Entry, Label)        \
  21.     {                            \
  22.     fflush(NULL); printf("\n");            \
  23.     printf("\tNumber Entered:  %.f", (double)Entry);\
  24.     printf(" (%s)\n", Label);            \
  25.     }
  26. #define    SHOW_INT_VALUE_USED(Entered, Used)             \
  27.     printf("\tTest Value Used: %.f%s\n", (double)Used,    \
  28.     ((double)Entered == (double)Used) ? "" : " (Clamped)")
  29.  
  30. /* ==================================================================== */
  31. /* SetMaxOfTControls - Puts Run Controls in MaxtData structure        */
  32. /* ==================================================================== */
  33. void
  34. SetMaxOfTControls(MAXT_DATA_STRU *MaxtData)
  35. {
  36.     int     NewlineCh;
  37.     UINT    UserUintEntry;
  38.  
  39.     NewlineCh = _isatty(_fileno(stdin)) ? '\r' : '\n';
  40.  
  41.     /* ----------------------------------------------------------- */
  42.     /* Get Number of Sequences to be Used in Maximum-of-t Analysis */
  43.     /* ----------------------------------------------------------- */
  44.     GetUint(NEED_USER_ENTRY(SQNCE_LABEL, MIN_NUM_SQNCE, MAX_NUM_SQNCE),
  45.     &UserUintEntry);
  46.  
  47.     REPORT_USER_INT_ENTRY(UserUintEntry, SQNCE_LABEL);
  48.  
  49.     CLAMP(MaxtData->NumSequences, UserUintEntry,
  50.     (UINT)MIN_NUM_SQNCE, (UINT)MAX_NUM_SQNCE);
  51.  
  52.     SHOW_INT_VALUE_USED(UserUintEntry, MaxtData->NumSequences);
  53.  
  54.     fflush(NULL);fprintf(stderr, "%c", NewlineCh);
  55.     /* --------------------------------------- */
  56.     /* Get Number of Variates in Each Sequence */
  57.     /* --------------------------------------- */
  58.     GetUint(NEED_USER_ENTRY(LEN_LABEL, MIN_SQNCE_LEN, MAX_SQNCE_LEN),
  59.     &UserUintEntry);
  60.  
  61.     REPORT_USER_INT_ENTRY(UserUintEntry, LEN_LABEL);
  62.  
  63.     CLAMP(MaxtData->SequenceLen, (int)UserUintEntry,
  64.     MIN_SQNCE_LEN, MAX_SQNCE_LEN);
  65.  
  66.     SHOW_INT_VALUE_USED(UserUintEntry, MaxtData->SequenceLen);
  67.  
  68.     fflush(NULL);fprintf(stderr, "%c", NewlineCh);
  69. }
  70.